﻿using Abp.Application.Services;
using Sunlit.Business.Serves.Dto;
using Abp.Domain.Repositories;
using System.Linq;
using Abp.Linq.Extensions;
using Abp.Extensions;

namespace Sunlit.Business.Serves
{
    public class ServeAppService: AsyncCrudAppService<Serve, ServeDto,long,GetAllServeInput,
        CreateServeInput,UpdateServeInput>,IServeAppService
    {
        public ServeAppService(IRepository<Serve, long> repository): base(repository)
        {

        }
        protected override IQueryable<Serve> CreateFilteredQuery(GetAllServeInput input)
        {
            return base.CreateFilteredQuery(input)
                .WhereIf(!input.Title.IsNullOrEmpty(), p => p.Title.Contains(input.Title))
                .WhereIf(input.RegionId.HasValue, p => p.RegionId == input.RegionId)
                .WhereIf(input.CreatorUserId.HasValue, p => p.CreatorUserId == input.CreatorUserId)
                .WhereIf(input.ServeCateId.HasValue, p => p.ServeCateId == input.ServeCateId);
        }
    }
}
